package inner;

class OuterClass2 {
    public int data1 = 1;
    int data2 = 2;
    public static int data3 = 3;
    public void test(){
        System.out.println("OuterClass:test()");
    }

    /**
     *   静态内部类
     *   1. 如何获取 静态内部类的对象
     *     OuterClass2.InnerClass2 innerClass2 = new OuterClass2.InnerClass2();
     *   2. 静态内部类当中，不能访问外部类的非静态成员，外部类的非静态成员，需要通过外部类的对象的引用才能访问
     *   非要访问： OuterClass2 outerClass2 = new OuterClass2();
     *            System.out.println(outerClass2.data1);
     *            System.out.println(outerClass2.data2);
     */
    static class InnerClass2{
        public int data4 = 4;
        int data5 = 5;
        public static int data6 = 6;
        public void func(){
            System.out.println("InnerClass:func()");
            OuterClass2 outerClass2 = new OuterClass2();
            System.out.println(outerClass2.data1);
            System.out.println(outerClass2.data2);
            /*System.out.println(data1);//error
            System.out.println(data2);//error*/
            System.out.println(data3);//3
            System.out.println(data4);//4
            System.out.println(data5);//5
            System.out.println(data6);//6
        }
    }
}
public class Test2 {
    OuterClass2.InnerClass2 innerClass2 = new OuterClass2.InnerClass2();
}
